package com.yict.csms.system.util;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

import com.yict.common.util.ObjectUtil;
import com.yict.csms.system.entity.DataDict;

public class ShiftTimeUtil {
	public static Date getStartTime(DataDict shiftTime,Date date){
		String fromToStr = shiftTime.getDatavalue();
		if(fromToStr == null) return null;
		String[] fromToArr = fromToStr.split("-");
		if(fromToArr.length != 2) return null;
		String[] fromFields = fromToArr[0].split(":");
		if(fromFields.length != 3) return null;
		Calendar calendar = Calendar.getInstance();
		if(date != null) calendar.setTime(date);
		
		calendar.set(Calendar.HOUR_OF_DAY, ObjectUtil.s2i(fromFields[0]));
		calendar.set(Calendar.MINUTE, ObjectUtil.s2i(fromFields[1]));
		calendar.set(Calendar.SECOND, ObjectUtil.s2i(fromFields[2]));
		calendar.set(Calendar.MILLISECOND, 0);
		
		return calendar.getTime();
	} 
}
